using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class JobSeekers_personal : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        else
        {
            if(!IsPostBack)
                EditPersonalInfo();
        }
    }
    void EditPersonalInfo()
    {
        SQLServerProviders cls = new SQLServerProviders();
        DataTable dataTable =
        cls.GetDataTable("select * from vwJSPersonalInfo" +
        " where UserID='" + Session["jsuserid"] +
         "'", CommandType.Text);
        txtPermanent.Text = dataTable.Rows[0][1].ToString();
        txtResident.Text = dataTable.Rows[0][2].ToString();
        txtCity.Text = dataTable.Rows[0][3].ToString();
        txtDOB.Text = dataTable.Rows[0][4].ToString();
        rblGender.SelectedValue=  (dataTable.Rows[0][5].ToString()=="True")?"1":"0" ;
        rblMaritalStatus.SelectedValue= dataTable.Rows[0][6].ToString() ;
        ddlCountry.SelectedValue = dataTable.Rows[0][7].ToString();
        ddlProvince.SelectedValue =  dataTable.Rows[0][8].ToString() ;
        ddlRace.SelectedValue = dataTable.Rows[0][9].ToString();
        btnNext.Text="Update";
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        SQLServerProviders  cls = new  SQLServerProviders();
        if(!cls.UpdatePersonal(Convert.ToString(
        Session.Contents["jsuserid"]),
        txtPermanent.Text,
        txtResident.Text,
        Convert.ToInt16(ddlProvince.SelectedValue),
        txtCity.Text,txtDOB.Text,
        ((rblGender.SelectedItem.Value=="0")?false:true),
        Convert.ToInt16(rblMaritalStatus.SelectedItem.Value),
        Convert.ToInt16(ddlRace.SelectedValue))) 
            literalError.Text="Error: "+ cls.ErrorMessage;  
        else   
            if(btnNext.Text=="Update")
                Response.Redirect("educations.aspx");
            else  
                Response.Redirect("education.aspx");
    }
}
